#include "StdAfx.h"
#include "ConsumerHouseModel.h"


ConsumerHouseModel::ConsumerHouseModel(void)
{
	m_id = -1;
	m_consumerID = -1;
	m_houseType = -1;
	m_houseAddr = ""; 
	m_appraisement = _T("");
	m_houseArea = -1;
	m_propertyRight = -1;
	m_installmentBank = "";
	m_loanTime = -1;
	m_loanSum = _T("");
	m_monthPay = _T("");
	m_dueSum = _T("");
	m_cutPaymentCard = -1;
	m_memo = _T("");
}

ConsumerHouseModel::~ConsumerHouseModel(void)
{
}

void ConsumerHouseModel::parseFromJson(Json::Value& jsonData)
{
	if (!jsonData["houseType"].isNull()) 
	{
		this->m_houseType = jsonData["houseType"].asInt();
	}
	CUtils::getJsonStringField(jsonData, "houseAddr", m_houseAddr);
	if (!jsonData["area"].isNull()) 
	{
		this->m_houseArea = jsonData["area"].asInt();
	}
	if (!jsonData["propertyRight"].isNull()) 
	{
		this->m_propertyRight = jsonData["propertyRight"].asInt();
	}
	if (!jsonData["loanTime"].isNull()) 
	{
		this->m_loanTime = jsonData["loanTime"].asInt();
	}
	if (!jsonData["koukuangCard"].isNull()) 
	{
		this->m_cutPaymentCard = jsonData["koukuangCard"].asInt();
	}
	CUtils::getJsonStringField(jsonData, "installmentBank", m_installmentBank);
	CUtils::getJsonStringField(jsonData, "appraisePrice", m_appraisement);
	CUtils::getJsonStringField(jsonData, "loanMoney", m_loanSum);
	CUtils::getJsonStringField(jsonData, "monthPay", m_monthPay);
	CUtils::getJsonStringField(jsonData, "jieqianMoney", m_dueSum);
	CUtils::getJsonStringField(jsonData, "houseMemo", m_memo);

}

void ConsumerHouseModel::toJson(Json::Value& jsonData)
{
	if (this->m_houseType >= 0) 
	{
		jsonData["houseType"] = this->m_houseType;
	}
	if (this->m_houseAddr >= 0) 
	{
		jsonData["houseAddr"] = this->m_houseAddr.GetBuffer();
	}
	if (this->m_appraisement.GetLength() > 0) 
	{
		jsonData["appraisePrice"] = this->m_appraisement.GetBuffer();
	}
	if (this->m_houseArea >= 0) 
	{
		jsonData["area"] = this->m_houseArea;
	}
	if (this->m_propertyRight >= 0) 
	{
		jsonData["propertyRight"] = this->m_propertyRight;
	}
	if (this->m_installmentBank >= 0) 
	{
		jsonData["installmentBank"] = this->m_installmentBank.GetBuffer();
	}
	if (this->m_loanTime >= 0) 
	{
		jsonData["loanTime"] = this->m_loanTime;
	}
	if (this->m_loanSum.GetLength() > 0) 
	{
		jsonData["loanMoney"] = this->m_loanSum.GetBuffer();
	}
	if (this->m_monthPay.GetLength() > 0)
	{
		jsonData["monthPay"] = this->m_monthPay.GetBuffer();
	}
	if (this->m_dueSum.GetLength() > 0) 
	{
		jsonData["jieqianMoney"] = this->m_dueSum.GetBuffer();
	}
	if (this->m_cutPaymentCard >= 0) 
	{
		jsonData["koukuangCard"] = this->m_cutPaymentCard;
	}
	if (this->m_memo.GetLength() >= 0) 
	{
		jsonData["houseMemo"] = this->m_memo.GetBuffer();
	}
}

